#include "led.h"

/* you need edit this code, port to your project */
#ifdef __SDCC
#define LED1 P2_0
#define LED2 P2_1
#else // Keil C51
sbit LED1 = P2^0;
sbit LED2 = P2^1;
#endif

void led_init(void)
{
    /* set led off */
    #ifdef LED1
    LED1 = 1;
    #endif

    #ifdef LED2
    LED2 = 0;
    #endif

}

volatile void led_toggle(uchar led)
{
    switch(led)
    {
        case 1:
            #ifdef LED1
            LED1 = !LED1;
            #endif
            break;
        case 2:
            #ifdef LED2
            LED2 = !LED2;
            #endif
            break;
    }
}

volatile void led_on(uchar led)
{
    switch(led)
    {
        case 1:
            #ifdef LED1
            LED1 = 0;
            #endif
            break;
        case 2:
            #ifdef LED2
            LED2 = 0;
            #endif
            break;
    }
}

volatile void led_off(uchar led)
{
    switch(led)
    {
        case 1:
            #ifdef LED1
            LED1 = 1;
            #endif
            break;
        case 2:
            #ifdef LED2
            LED2 = 1;
            #endif
            break;
    }
}
